Introduction to Pluto

Week 01

Author
Affiliation

Vivaldo Mendes

Instituto Universitário de Lisboa (ISCTE-IUL)

Published

February 3, 2025

Tasks in week 1

  • Everything in this course will be done using a computer
    • Practical exercises,
    • Mock tests/exams
    • Formal evaluation moments: tests/exams

Tasks in week 1

  • We have to install two programs on your computer:
    • Julia programming language
    • Pluto.jl (one package developed for Julia)
  • Week 1 deals only with the introduction to Pluto notebooks
  • No macroeconomics will be taught during this week
  • Do not worry: this is a macroeconomics course, not a computational one

1. Installing Julia

  • The following slides are a short version of more detailed information available here

Installing Julia on Windows

  • Download the correct executable for the Windows OS, by clicking here: Windows installer Julia v1.11.3
  • Save the downloaded executable somewhere on your computer, or keep it in the Downloads folder.
  • Click on top of the executable to install Julia
  • Allow the installation to be done in the default directory
  • Click on: Title of the document Add Julia to PATH
  • Click on: Finish
  • Installation completed

Installing Julia on a Mac

  1. Choose the correct Apple executable according to the processor (Intel/Rosetta or Apple Silicon) on your Mac: this means that you have to choose either (2) or (3) below.
  2. If your Mac has an Intel or Rosetta processor, you can download the correct executable from here: macOS x86 (Intel or Rosetta) Julia v1.11.3
  3. If your Mac has an Apple Silicon processor, you can download the correct executable from here: macOS (Apple Silicon) Julia v1.11.3
  4. Check the Downloads folder and drag the executable to the Applications folder. Installation completed.

Installing Julia on Linux

See detailed information available here

2. Running Julia

Starting Julia

  • To start Julia, click on its icon on the desktop:

\(~~~~~~~~~~~~~~~~~~~~~~~~~~~~\)

Starting Julia

  • The following black window will appear on your monitor: \(~~~~~\)

  • Julia runs in Two modes: Julia mode and Pkg mode

  • what are these modes for? Next slides

Julia mode

  • When we start Julia, by default it runs in Julia mode. In the image below, \(\color{red}{\text{julia>}}\) indicates that we are in this mode:

\(~~~~~~~~~\)

Julia mode

  • If you type after \(\color{red}{\text{julia>}}\) \(4+4\) , followed by clicking on Enter, you will get \(8\) as the output.

  • Julia is installed and running well.

  • Julia mode is for doing computation, but its window is ugly and not very handy

  • So for computation, we will use Pluto instead.

Pkg mode

  • To move from Julia mode to Pkg mode, in mode \(\color{red}{\text{julia>}}\) type the following character: \(\color{red}{\text{]}}\)
  • Different keyboards have different ways of typing \(\color{red}{\text{]}}\)
    • Alt Gr and 9 (usually do it on Windows)
    • Option and 9 (usually do it on Mac)

Pkg mode

  • Now, we see \(\color{blue}{\text{(@v1.11) pkg>}}\) in the black window indicating that we are in Pkg mode:

\(~~~~~~~~~\)

  • To go back to Julia mode, click on backspace: \(\longleftarrow\)

3. Installing Pluto

Installing Pluto

  • Start Julia, if it is not already running
  • Go to Pkg mode: \(\color{blue}{\text{(@v1.11) pkg>}}\)
  • Once in Pkg mode, type:
    • add Pluto followed by clicking on Enter
  • Let the computer do the installation: no further intervention by you is required
  • When the installation is finished, go back to mode \(\color{red}{\text{julia>}}\) by clicking on backspace: \(\longleftarrow\)
  • That is it: Pluto is installed on your computer.

4. Updating your installation

Updating Pluto

  • From time to time, new versions of Pluto come out
  • We recommend you to update your Pluto installation every two weeks
  • It is very simple and takes around 1 minute

Updating Pluto

  • Start Julia and go to mode: \(\color{blue}{\text{(@v1.11) pkg>}}\)
  • Once in Pkg mode, type:
    • Update followed by clicking on Enter
  • Let the computer update your system (you do not need to intervene during this process)
  • When the updating is finished, go back to mode \(\color{red}{\text{julia>}}\) by clicking on backspace: \(\longleftarrow\).
  • It is done.

5. Using Pluto

See more detailed information available here

Starting Pluto

  • Start Julia and keep it in mode \(\color{red}{\text{julia>}}\)
  • Type in its black window: import Pluto ; Pluto.run()
  • Click on Enter and Julia will open Pluto in your browser:
    \(~~~~~~~~~~~~~~\)

Opening a Pluto notebook

  • To open a Pluto notebook, the double-click on top of the file does not work
  • Neither do the usual drag-and-drop in Mac
  • Even if the drag-and-drop seems to work, do not do it … you will loose your work

Opening a Pluto notebook

You have to tell Pluto where your notebook is located. For this, you have to:

  • Put the Pluto notebook in a folder on your computer.
  • So your notebook has an address (Path) on your computer
  • You have to copy that address and paste it into Pluto’s Open a notebook window
  • How to get the address (Path) of your notebook?
  • See next slide

Copy your notebook’s path: Windows

Put the cursor on top of your file

  • Mouse right-click on your file
  • Choose: Properties
  • Copy the path in Location:
  • The Path will looke like this:
    \(~~~~~~\) G:\Macro\Week01
  • Once you have copied the path of your notebook, you canp aste it into the Open a notebook box in the Pluto window
  • See next slide

Copy your notebook’s path: Mac

Put the cursor on top of your file

  • Mouse right-click on your file
  • Choose: Get info
  • Copy the path in Where:
  • The Path will looke like this:
    \(~~~~~~\) G:/Macro/Week01
  • Once you have copied the path of your notebook, you can paste it into the Open a notebook box in the Pluto window
  • See next slide

Paste the Path of your notebook into Pluto

\(~~~~~~~~~~~~~~\)

  1. Your Pluto notebook will be opened and running in your browser

End